
<style>
    .form-horizontal .form-group{margin-right: -50px;}
    .col-sm-8{padding-right: 0;}
	.tm .btn { margin-bottom:5px;}
</style>
<div class="page-content">
    <div class="row">
        <div class="col-sm-8">
            <div class="">
                <div class="summary_box">
                    <div class="summary_title">
                        <span class="title_inner">短信模板说明</span>
                    </div>
                    <div class="summary_lg">
                        <p>模板名称：自定义填写，便于后台搜索查询选择。</p>
                        <p>模板ID：聚合数据、阿里通信需在服务商申请短信模板并审核，模板ID处填写服务商申请的模板ID。</p>
                        <p>短信签名: 阿里通信需在服务商申请短信签名并审核，短信签名处填写服务商申请的短信签名</p>
                        <p>数据值：聚合数据、阿里通信需在数据值中填写服务商模板变量对应的商城的变量(可在右侧选择商城变量)。</p>
                        
                        <p>状态：商城短信模板状态，关闭后将不能选择此模板，关闭后仍可在模板列表发送测试短信。</p>
                        <p class="text-danger">注意：阿里通信同一手机号60秒内只能发送一次，请根据需求选择适当接口。</p>
                    </div>
                </div>
            </div>
            <form action="" method="post" class="form-horizontal form-validate" enctype="multipart/form-data">
            <input type="hidden" name="template" value="" />
            <div class="form-group" style="margin-top:20px">
                <label class="col-xs-12 col-sm-3 col-md-2 right-label" >模板名称</label>
                <div class="col-xs-12 col-sm-8 col-lg-9">
                    <input type="text" name="name" ng-model="pagedata.item.title" class="form-control" value="" placeholder="模版名称，例：订单创建成功通知（自定义）" data-rule-required='true' />
                    
                </div>
            </div>
            <!--<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 right-label" >服务商</label>
					<div class="col-xs-12 col-sm-8 col-lg-9">
                    <select id="selecttemplate"  class=" form-control" style="margin-bottom: 5px;" ng-model="pagedata.item.type">
                     <option   value="1">阿里通信</option>
					  <option   value="2">聚合短信</option>
					</select>
                    </div>
             </div>-->
            <div class="form-group sms-template-1" >
                <label class="col-xs-12 col-sm-3 col-md-2 right-label" >模板ID</label>
                <div class="col-xs-12 col-sm-8 col-lg-9">                
                    <input type="text" name="smstplid" class="form-control" value="" ng-model="pagedata.item.smstplid" placeholder="短信模板ID，例：1234（短信服务商提供的模板ID）" data-rule-required='true' />
                    <div class="help-block">服务商提供的模板ID</div>           
                </div>
            </div>
            <div class="form-group splitter sms-template-1"></div>
            <div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">设置消息内容</label>
					<div class="col-sm-9 col-xs-12">
						<textarea id="content" name="content" ng-model="pagedata.item.content" style="height: 150px;resize: none;" class="form-control" placeholder='支持<a href=""></a>标签' >{{pagedata.item.content}}</textarea>
						<div class="edit" style="width: 100%;height: 30px;border-bottom:1px solid #e5e6e7;border-left:1px solid #e5e6e7;border-right:1px solid #e5e6e7;">
							<div style="width: 30px;height: 30px;float: left;margin-left: 20px">
								<a href="javascript:" id="link" title="插入链接">
									<img src="../addons/jy_weishop/images/link.png" width="18px" height="18px" style="margin-top: 7px;">
								</a>
							</div>
						</div>
						 <div class="help-block">
						 右侧选择模板变量类型---选择变量--插入变量。短信会自动替换成为“真实内容”;
						 </br>1、阿里通信：请设置${ordersn}变量
						 </br>2、短信通：暂无需模板ID，无需设置变量；
						 </br>3、聚合短信：请设置#ordersn#变量用于接收验证码
						 </div>
					</div>
			</div>
			<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 left-label">阿里模板内容</label>
					<div class="col-sm-9 col-xs-12">
						<div style="background:#f2f2f2;padding:10px;min-height:100px;position: relative;">
						{{pagedata.item.smscontent || '暂无内容'}}
						<span style="position: absolute;right:10px;top:10px">
							<button class="btn btn-success" type="button" ng-click="pagedata.upsmscont()">刷新模板内容</button>
						</span>
						</div>
						 <div class="help-block">直接复制上面的模板内容，前往阿里云创建模板！</div>
					</div>
			</div>
            <div class="form-group" style="margin-top:20px">
                <label class="col-xs-12 col-sm-3 col-md-2 right-label" >状态</label>
                 <div class="col-xs-12 col-sm-8 col-lg-9">
                    <label class="right-label">
						<div ng-show="pagedata.item.status==1" class="switch switchOn" ng-click="pagedata.item.status=0"></div>
						<div ng-show="pagedata.item.status!=1" class="switch" ng-click="pagedata.item.status=1"></div>
					</label>
				</div>
            </div>

			<div class="modal-sub"><button class="btn btn-primary"  href="javascript:" id="showTooltips" ng-click="post(pagedata.item,'post')">提交</button></div>
            </form>

        </div>
        <div class="col-sm-4" style="max-width:350px;">
            <div class="">
				<div ng-repeat="item in pagedata.msgtpl_tags" class="panel panel-default">
					<div class="panel-heading">
						{{item.title}}
					</div>
					<div class="panel-body tm tm-upgrade">
						<a ng-repeat="v in item.data" href='JavaScript:' class="btn btn-default btn-sm" style="margin-left:3px">{{v.name}}</a>
					</div>
				</div>
				<div class="panel-body">
						点击变量后会自动插入选择的文本框的焦点位置，在发送给粉丝时系统会自动替换对应变量值
						<div class="text text-danger">
							注意：以上模板消息变量只适用于系统类通知，会员群发工具不适用
						</div>
				</div>
			</div>
        </div>
    </div>
</div>
<script>
scope.pagedata.upsmscont=function(){
	var content=scope.pagedata.item.content
	if(content){
		scope.get('core/setting.sms_temp/upcontent/content='+content,function(res){
			//console.log(res);
			scope.pagedata.item.smscontent=res.smscontent;
			scope.$evalAsync();
		});
	}
}
scope.pagedata.upsmscont();
</script>
<script>
 $(function () {
        require(['jquery.caret'],function(){
            var jiaodian;
            $(document).on('focus', 'input,textarea',function () {
                jiaodian = this;
            });

            $("a[href='JavaScript:']").click(function () {
                if (jiaodian) {
                    $(jiaodian).insertAtCaret("["+this.innerText+"]" );	
					scope.pagedata.item.content=$("#content").val();
					scope.pagedata.upsmscont();
                }
            })

        })
    })
    require(['jquery','util'], function($, util){
        $(function(){
            $('#btn').click(function(){
                util.emojiBrowser(function(emoji){
                    var text = '[U+'+emoji[0].text+']';
                    var content = $('#content').val()+text;
                    $('#content').val(content);
                });
            });
        });

        $(function(){
            util.emotion($('#emotion'), $('#content'));
        });

        $(function () {
            $('#link').click(function () {
                var link='<a href=\\"您要插入的链接\\">链接文字</a>';
                var content = $('#content').val()+link;
                $('#content').val(content);
            });
        });
    });
</script>

